package com.kangkang.creationalpattern;

public class Singleton3 {
    /*
     * 懒汉式创建单例模式 由于懒汉式是非线程安全， 使用同步代码块
     */
    private static Singleton3 singleton;

    private Singleton3() {
    }

    public static Singleton3 getInstance() {
        synchronized (Singleton3.class) {
            if (singleton == null) {

                singleton = new Singleton3();
            }
        }
        return singleton;
    }
}
